package com.demo.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.demo.entity.AppInfo;
import com.demo.service.AppInfoService;

/**********************************************************
 *
 * 文件名称：HelloWorld.java 
 * 摘    要：
 *
 * 初始版本：1.0.0.0
 * 原 作 者：叶平平
 * 完成日期：2015-12-24 下午4:35:11
 * 
 ************************************************************/
@Controller
@RequestMapping(value="test")
public class HelloBeetlController {
	
	@Autowired
	private AppInfoService appInfoService;

	@RequestMapping(value="helloBeetl")
	public ModelAndView helloBeetl(ModelMap model){
		String message = "Hello World, Spring 3.2 beetl!";
		model.addAttribute("name","joel");
		model.addAttribute("currUser","libear");
		return new ModelAndView("/html/hello", "message", message);
	}
	
	@RequestMapping(value="helloJsp")
	public ModelAndView helloJsp(ModelMap model){
		String message = "Hello World, Spring 3.2 jsp!";
		model.addAttribute("name","joel");
		model.addAttribute("currUser","libear");
		return new ModelAndView("/jsp/hello", "message", message);
	}
	
	@RequestMapping(value="helloJson")
	@ResponseBody
	public Map helloJson(){
		Map map = new HashMap();
		map.put("name", "joel");
		map.put("sex", "man");
		return map;
	}
	
	@RequestMapping(value="queryAppInfos")
	@ResponseBody
	public List<AppInfo> queryAppInfos(){
		return appInfoService.queryAppInfos();
	}
}
